package com.zwr.sheller.customer.Service.Impl;

import com.zwr.sheller.core.util.SMSSend;
import com.zwr.sheller.customer.Service.SendCodeSmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 *
 *@author Kang
 *@date
 */
@Service("sendCodeSmsService")
public class SendCodeSmsServiceImpl implements SendCodeSmsService {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    public static  final String CODE_SMS="code_sms:";
    @Override
    public String sendLoginSms(String phone) {
        String msgCode = SMSSend.getMsgCode();
        System.out.println("++++++++验证码:"+msgCode+"+++++++++");
        //服务器这是失效时间为30min
        redisTemplate.opsForValue().set(CODE_SMS+phone,msgCode,30, TimeUnit.MINUTES);
        return msgCode;
    }
}
